package desktop.playerguide;

import pulpcore.Input;
import pulpcore.Stage;
import pulpcore.image.CoreImage;
import pulpcore.scene.Scene2D;
import pulpcore.sprite.Button;
import pulpcore.sprite.ImageSprite;
import pulpcore.sprite.Label;

public class GameOverScene extends Scene2D {
	
	Label label;
	double score;
	Button restart;
	CoreImage[] coreImageArray = new CoreImage[3];
	
	public GameOverScene(double score) {
		this.score = score;
	}
	
	@Override
	public void load() {
		super.load();
		CoreImage coreImage = CoreImage.load("failed.jpg");
		ImageSprite im = new ImageSprite(coreImage,0,0,Stage.getWidth(),Stage.getHeight());
		add(im);
		Label scoreLabel = new Label("Game is over,and your score is %d", 
				Stage.getWidth()/2, Stage.getHeight()/2);
		scoreLabel.setFormatArg(score);
        add(scoreLabel);
        CoreImage buttonImage0 = CoreImage.load("button0.png");
        CoreImage buttonImage1 = CoreImage.load("button1.png");
        CoreImage buttonImage2 = CoreImage.load("button2.png");
        coreImageArray[0] = buttonImage0;
        coreImageArray[1] = buttonImage1;
        coreImageArray[2] = buttonImage2;
        restart = new Button(coreImageArray, 
        		Stage.getWidth()*0.75, Stage.getHeight()*0.75);
        restart.setAnchor(0.5, 0);
        restart.setKeyBinding(Input.KEY_ENTER);
        add(restart);
	}
	
	@Override
	public void update(int elapsedTime) {
		super.update(elapsedTime);
		if(restart.isClicked()){
			this.getMainLayer().removeAll();
			Stage.pushScene(new PlayerGuideScene());
		}
	}
}
